palette: return the same values if same name is provided
authorØyvind Kolås <pippin@gimp.org>
Thu, 29 Mar 2012 23:14:49 +0000 (00:14 +0100)
committerØyvind Kolås <pippin@gimp.org>
Thu, 29 Mar 2012 23:24:23 +0000 (00:24 +0100)
babl/babl-palette.c
babl/babl.h

index 535924383fbded3e9fa2f366c5bc8bf806be11b8..7e72eaa15398bbb192b33fe4c06975ca6c252d15 100644 (file)
@@ -481,6 +481,17 @@ const Babl *babl_new_palette (const char  *name,
     {
       strcpy (cname, name);
       name = cname;
+
+      if ((model = babl_db_exist_by_name (babl_model_db (), name)))
+        {
+          cname[0] = ')';
+          if (format_u8)
+            *format_u8 = babl_db_exist_by_name (babl_format_db (), name);
+          cname[0] = '\\';
+          if (format_u8_with_alpha)
+            *format_u8_with_alpha = babl_db_exist_by_name (babl_format_db (), name);
+          return model;
+        }
     }
 
   /* re-registering is a no-op */
@@ -496,11 +507,11 @@ const Babl *babl_new_palette (const char  *name,
   *palptr = default_palette ();;
   cname[0] = 'v';
   model_no_alpha = babl_model_new ("name", name, component, NULL);
-  cname[0] = 'x';
+  cname[0] = '\\';
   f_pal_a_u8 = (void*) babl_format_new ("name", name, model,
                                 babl_type ("u8"),
                                 component, alpha, NULL);
-  cname[0] = 'y';
+  cname[0] = ')';
   f_pal_u8  = (void*) babl_format_new ("name", name, model_no_alpha,
                                babl_type ("u8"),
                                component, NULL);
index 80333c0917567442b79ec30fbf8e1bd62080085e..5e6cf42ff787bec3eb5ee9b1b406070d4481c95f 100644 (file)
@@ -204,7 +204,9 @@ const Babl * babl_conversion_new (const void *first_arg,
 /**
  * create a new palette based format, name is optional pass in NULL to get
  * an anonymous format. If you pass in with_alpha the format also gets
- * an 8bit alpha channel. Returns the BablModel of the color model.
+ * an 8bit alpha channel. Returns the BablModel of the color model. If
+ * you pass in the same name the previous formats will be provided
+ * again.
  */
 const Babl *babl_new_palette (const char  *name,
                               const Babl **format_u8,